package BanyuanClub.Work.Day0223.GongJu;

import java.util.Objects;

/**
 * 该类有band、color和price三个属性，生成equals、hashcode和toString方法
 */
public class Car {
    private int band;
    private String color;
    private int price;

    @Override
    public String toString() {
        return "Car{" +
                "band=" + band +
                ", color='" + color + '\'' +
                ", price=" + price +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Car car = (Car) o;
        return band == car.band &&
                price == car.price &&
                Objects.equals(color, car.color);
    }

    @Override
    public int hashCode() {
        return Objects.hash(band, color, price);
    }
}
